<?php
/*
	插件概览		
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'welcome';
$tabs=array(
	array('op'=>'welcome','title'=>'概况'),
	array('op'=>'line','title'=>'趋势'),
);
set_html('tabs',$tabs);
if($_RQ['op']=='welcome'){
	//会员
	$order=array(
		'num'=>$this->count('orderlog',array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0)),
		'order_price'=>$this->getsum('orderlog',array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0),'order_price'),
		'member'=>$this->count('member',array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0)),
		'get_money'=>$this->count('orderlog',array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0),'get_money'),
	);
	$return['htmls'][]=array('type'=>'data','one_num'=>3,'title'=>'订单概况','datas'=>array(
		array('title'=>'总订单数','num'=>1,'data'=>$order['num']),
		array('title'=>'总订单额','num'=>1,'data'=>$order['order_price']),
		array('title'=>'总配送员','num'=>1,'data'=>$order['member']),
		array('title'=>'总配送费','num'=>1,'data'=>$order['get_money']),
	));
	//佣金
	$data=array(
		'num'=>pdo_count('jy_weishop_member',array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0)),
		'ordernum'=>$this->count('orderlog',array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0),'order_price'),
		'merchnum'=>pdo_count('jy_merch_user',array('uniacid'=>$_SESSION['uniacid'])),
	);
	$return['htmls'][]=array('type'=>'data','one_num'=>4,'title'=>'数据概况','datas'=>array(
		array('title'=>'总用户','num'=>1,'data'=>$data['num']),
		array('title'=>'总成交量','num'=>1,'data'=>$data['ordernum']),
		array('title'=>'总商户数','num'=>1,'data'=>$data['merchnum']),
	));
	
	$order_pie=array(
		'title'=>'订单概况',
		'tablename'=>$this->tablename('orderlog'),
		'width'=>'50%',
		'field'=>'status',
		'field_options'=>$this->send_status,
		'params'=>array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0),
	);
	$return['htmls'][]=model('core/echart')->pie($order_pie);
	$fee_pie=array(
		'title'=>'配送费概况',
		'tablename'=>$this->tablename('orderlog'),
		'width'=>'50%',
		'field'=>'type',
		'field_options'=>$this->feetypes,
		'params'=>array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0),
	);
	$return['htmls'][]=model('core/echart')->pie($fee_pie);
	set_html('title','分销概况');
	exi($return);
}
if($_RQ['op']=='line'){
	//趋势
	$order_params=array(
		'title'=>'近30天订单走势',
		'data'=>array(
			'tablename'=>$this->tablename('orderlog'),
			'params'=>array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0),
		),
	);
	$return['htmls'][]=model('core/echart')->line($order_params);
	$member_params=array(
		'title'=>'近三十天商户/配送员增长走势',
		'data'=>array(
			'商户增长'=>array(
				'tablename'=>'jy_merch_user',
				'params'=>array('uniacid'=>$_SESSION['uniacid']),
				'time_field'=>'jointime',
			),
			'配送员增长'=>array(
				'tablename'=>$this->tablename('member'),
				'params'=>array('uniacid'=>$_SESSION['uniacid'],'merchid >'=>0),
			)
		),
	);
	$return['htmls'][]=model('core/echart')->line($member_params);
	set_html('title','配送员趋势');
	exi($return);
}